#include<iostream>
#include<deque>
#include<algorithm> //sort迭代器
using namespace std;

void print(const deque<int> &d) {
    for (deque<int>::const_iterator it = d.begin(); it != d.end(); it++) {
        cout << *it<<" ";
    }
    cout << endl;
}
void test01(int n) {
    deque<int> d1;
    for (int i = 0; i < n; i++) {
        cin>>d1.emplace_back();
    }
    cout<<"排序前:"<<endl;
    print(d1);
    sort(d1.begin(), d1.end());
    cout<<"排序后:"<<endl;
    print(d1);
}

int main()
{
    int n;
    cin >> n;
    test01(n);
    return 0;
}